#!/bin/bash

CUR_DIR=$(cd "$(dirname "${BASH_SOURCE-$0}")"; pwd)
source ${CUR_DIR}/../system.properties
if [ -z $SPARK_HOME ];then
    export SPARK_HOME=/usr/hdp/2.6.4.0-91/spark2
fi
if [ -z $HADOOP_USER_NAME ];then
    export HADOOP_USER_NAME=hdfs
fi

echo "SPARK_HOME:${SPARK_HOME}"
echo "HADOOP_USER_NAME:${HADOOP_USER_NAME}"

#输出日期的路径
OUT_DATE_PROP_FILE="${CUR_DIR}/../outdate.properties"
doExistForDate(){
    echo "Please run create_statistical_date.sh first to create Date Params"
    echo "Exit!-----"
    exit 1
}

if [ -f  ${OUT_DATE_PROP_FILE} ];then
	source ${OUT_DATE_PROP_FILE}
	[ -z "${day_date}" ] && doExistForDate
	[ -z "${week_start_date}" ] && doExistForDate
	[ -z "${month_start_date}" ] && doExistForDate
else
   doExistForDate
fi


#从xml文件中获取指定标签的内容
getXmlContentValue()
{
        local IFS=\>
        while read -d \< ENTITY CONTENT
        do
                TAG_NAME=${ENTITY%% *}
                if [[ $TAG_NAME == $2 ]]
                then
                			CONTENT=$(echo "$CONTENT" | tr "\n" " "  )
                			CONTENT=$(eval "echo $CONTENT")
                        echo $CONTENT
                fi
        done < $1
}